package com.vue.controller;

import com.vue.bean.R;
import com.vue.service.IWeChatService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: wrj
 * @since: 2024/8/3 20:12
 * @description:
 */

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/weChat")
public class WxLoginController {

    private final IWeChatService weChatService;

    @GetMapping("login")
    public R login(String code) {
        log.info("微信小程序登录:{}", code);
        try {
            return weChatService.login(code);
        } catch (Exception e) {
            e.printStackTrace();
            return R.fail(e.getMessage());
        }
    }
}
